//
//  ImageDemoView.m
//  JackToolsBox
//
//  Created by Blue on 2019/12/11.
//  Copyright © 2019 Jack Xue. All rights reserved.
//

#import "ImageDemoView.h"

@implementation ImageDemoView
{
    UIButton *_clearBtn;
    UIButton *_nextBtn;
}

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor whiteColor];
        
        _clearBtn = [[UIButton alloc] initWithFrame:CGRectZero];
        [_clearBtn setTitle:@"清楚缓存" forState:UIControlStateNormal];
        [_clearBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        [self addSubview:_clearBtn];
        
        _nextBtn = [[UIButton alloc] initWithFrame:CGRectZero];
        [_nextBtn setTitle:@"查看demo" forState:UIControlStateNormal];
        [_nextBtn setTitleColor:[UIColor blueColor] forState:UIControlStateNormal];
        [self addSubview:_nextBtn];
    }
    return self;
}

- (void)dealloc
{
    _clearBtn = nil;
    _nextBtn = nil;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
    _clearBtn.frame = CGRectMake(20, 100, self.bounds.size.width-2*20, 44);
    _nextBtn.frame = CGRectMake(20, CGRectGetMaxY(_clearBtn.frame)+20, CGRectGetWidth(_clearBtn.frame), 44);
}


- (void)setDelegate:(id)delegate
{
    _delegate = delegate;
    
    [_clearBtn addTarget:delegate action:@selector(clearAction) forControlEvents:UIControlEventTouchUpInside];
    [_nextBtn addTarget:delegate action:@selector(doNext) forControlEvents:UIControlEventTouchUpInside];
}
@end
